home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_024 / conquest / conqs1.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  3KB  |  83 lines

  1. #include "defs.h"
  2. #include "structs.h"
  3. #include "vars.h"
  4. #include <stdio.h>
  5.  
  6.  
  7. double sqrt();
  8. set_des(tf_num, Err0r)
  9. int tf_num;
  10. boolean *Err0r;
  11. {
  12.         boolean error;
  13.         int st_num,min_eta; 
  14.         char istar; 
  15.         float r;
  16.         int rge, dst;
  17.         int from_star;
  18.         if ( (tf[player][tf_num].eta != 0) ) { /*cancel*/
  19.                 tf[player][tf_num].eta = 0;
  20.                 from_star = 
  21.                   board[tf[player][tf_num].x][tf[player][tf_num].y].star-'A'+1;
  22.                 tf[player][tf_num].dest = from_star;
  23.                 tf_stars[from_star][player]++;
  24.                 printf("(Cancelling previous orders)");
  25.                 point(1,y_cursor + 1);
  26.         };
  27.         error = true;
  28.         printf(" to star:");
  29.         point(10,y_cursor);
  30.         get_char(&istar);
  31.         st_num = istar-'A'+1;
  32.         if ( (st_num<0) || (st_num>nstars) ) {
  33.                 error_message();
  34.                 printf("  !illegal star");
  35.         }
  36.         else {
  37.                 r=sqrt((float) (((stars[st_num].x-tf[1][tf_num].x)*
  38.                         (stars[st_num].x-tf[1][tf_num].x)) +
  39.                         ((stars[st_num].y-tf[1][tf_num].y) * 
  40.                         (stars[st_num].y-tf[1][tf_num].y))));
  41.                 point(1,y_cursor + 1);
  42.                 printf("   distance:%5.1f", r);
  43.                 dst = r - 0.049 + 1;
  44.                 if ( ( dst  > range[player] ) &&
  45.                         ( (tf[1][tf_num].b != 0) ||
  46.                                 (tf[1][tf_num].c != 0) ||
  47.                                 (tf[1][tf_num].t != 0) ) ) {
  48.                         error_message();
  49.                         printf("  !maximum range is %2d",
  50.                         range[player]);
  51.                 }
  52.                 else if ( r < 0.5 ) {
  53.                         point(1,y_cursor + 1);
  54.                         printf("Tf remains at star");
  55.                 }
  56.                 else {
  57.                         min_eta= ( (dst-1) / vel[player]) + 1;
  58.                         point(1,y_cursor + 1);
  59.                         printf("eta in %2d turns", min_eta);
  60.                         tf_stars[tf[player][tf_num].dest][player]--;
  61.                         tf[player][tf_num].dest=st_num;
  62.                         tf[player][tf_num].eta = min_eta;
  63.                         tf[player][tf_num].origeta= tf[player][tf_num].eta;
  64.                         tf[player][tf_num].xf= tf[player][tf_num].x;
  65.                         tf[player][tf_num].yf=tf[player][tf_num].y;
  66.                         error = false;
  67.                 }
  68.         }
  69.         *Err0r = error;
  70. }
  71.  
  72.  
  73. double
  74. fmin(a, b)
  75. double a, b;
  76. {
  77.         if (a < b)
  78.                 return(a);
  79.         else
  80.                 return(b);
  81. }
  82.  
  83.